<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<title>修改档案</title>
  <link rel="stylesheet" href="../../../layui/css/layui.css">
  <script src="../../../layui/layui.js"></script>
    <script type="text/javascript" src="../../../js/jquery-2.1.1.min.js"></script>
    <script type="text/javascript" src="../../../js/main.js"></script>
    <link rel="stylesheet" href="../../../js/zyupload/skins/zyupload-1.0.0.min.css " type="text/css">
    <script type="text/javascript" src="../../../js/zyupload/zyupload-1.0.0.min.js"></script>
</head>
<style type="text/css">
 body{
  height: 100%;
  width: 100%;
 }
 .layui-form-label{width: 130px}
 .btn {
    background-color: #e5e5e5;
    background-image: none;
    filter: none;
    border: 0;
    padding: 7px 14px;
    text-shadow: none;
    font-family: "Segoe UI", Helvetica, Arial, sans-serif;
    font-size: 14px;
    color: #333333;
    cursor: pointer;
    outline: none;
    -webkit-box-shadow: none !important;
    -moz-box-shadow: none !important;
    box-shadow: none !important;
    -webkit-border-radius: 0 !important;
    -moz-border-radius: 0 !important;
    border-radius: 0 !important;
}
.layui-input-inline{width: 214px !important}
</style>

<body>
 <!-- 内容主体区域 -->
 <div class="x-body layui-anim layui-anim-up">
  <div class="layui-fluid">
  
    <form class="layui-form layui-form-pane1" lay-filter="first" >

      <div class="layui-form-item">
          <div class="layui-inline">
          <label class="layui-form-label"><span class="text-error">*</span>会员姓名：</label>
          <div class="layui-input-inline">
              <input name="memberName" id="memberName" placeholder="请输入" value="" class="layui-input">
          </div>
      </div>

          <div class="layui-inline">
              <label class="layui-form-label"><span class="text-error">*</span>电话号码：</label>
              <div class="layui-input-inline">
                  <input name="tel" id="tel" placeholder="请输入" value="" class="layui-input">
              </div>
          </div>

      </div>
        <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label"><span class="text-error"></span>性别：</label>
            <div class="layui-input-inline">
                <select name="gender" id="gender" lay-verify="required" lay-search=""  lay-filter="parentSerSelect">
                    <option value="0">男</option>
                    <option value="1">女</option>
                </select>
            </div>

        </div>

            <div class="layui-inline">
                <label class="layui-form-label"><span class="text-error">*</span>微信：</label>
                <div class="layui-input-inline">
                    <input name="weixin" id="weixin" placeholder="请输入" value="" class="layui-input">
                </div>
            </div>
        </div>
       <div class="layui-form-item">
           <div class="layui-inline"  >
               <label class="layui-form-label" >生日：</label>
               <div class="layui-input-inline">
                   <input type="text" class="layui-input" id="birthday" name="birthday" placeholder="yyyy-MM-dd">
               </div>
           </div>



           <div class="layui-inline" id="periodPerTimeType">
               <label class="layui-form-label">星座：</label>
               <div class="layui-input-inline">
                   <input name="zodiac" id="zodiac" placeholder="请输入"  value="" class="layui-input">
               </div>
           </div>
       </div>



        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label"><span class="text-error"></span>会员类别：</label>
                <div class="layui-input-inline">
                    <select name="memberGrade" id="memberGrade" lay-verify="required" lay-search=""  lay-filter="parentSerSelect">
                        <option value="">请选择</option>
                        <option value="0">A类</option>
                        <option value="1">B类</option>
                        <option value="2">C类</option>
                        <option value="3">D类</option>
                    </select>
                </div>

            </div>
        <div class="layui-inline"  >
            <label class="layui-form-label">血型：</label>
            <div class="layui-input-inline">
                <input name="bloodType" id="bloodType" placeholder="请输入"  value="" class="layui-input">
            </div>
        </div>
        </div>
        <div class="layui-form-item">
        <div class="layui-inline"  id="priceType">
            <label class="layui-form-label" id="priceLabel">身高：</label>
            <div class="layui-input-inline">
                <input name="height" id="height" placeholder="请输入"  value="" class="layui-input">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">体重：</label>
            <div class="layui-input-inline">
                <input name="weight" id="weight" placeholder="请输入"  value="" class="layui-input">
            </div>
        </div>
        </div>
        <div class="layui-form-item" >
            <div class="layui-inline">
            <label class="layui-form-label">上次月经时间：</label>
            <div class="layui-input-inline">
                <input type="text" class="layui-input" id="lastDayOfMenses" name="lastDayOfMenses" placeholder="yyyy-MM-dd">

            </div>
            </div>

            <div class="layui-inline">
                <label class="layui-form-label">月经周期：</label>
                <div class="layui-input-inline">
                    <input name="cycleOfMenses" id="cycleOfMenses" placeholder="请输入"  value="" class="layui-input">
                </div>
            </div>
        </div>
        <div class="layui-form-item" >
            <div class="layui-inline">
                <label class="layui-form-label">经期长度：</label>
                <div class="layui-input-inline">
                    <input name="periodOfMenses" id="periodOfMenses" placeholder="请输入"  value="" class="layui-input">
                </div>
            </div>

            <div class="layui-inline">
                <label class="layui-form-label">月经备注：</label>
                <div class="layui-input-inline">
                    <input name="remarkOfMenses" id="remarkOfMenses" placeholder="请输入"  value="" class="layui-input">
                </div>
            </div>
        </div>

        <div class="layui-form-item" >
            <div class="layui-inline">
                <label class="layui-form-label">职业：</label>
                <div class="layui-input-inline">
                    <input name="profession" id="profession" placeholder="请输入"  value="" class="layui-input">
                </div>
            </div>

            <div class="layui-inline">
                <label class="layui-form-label">地址：</label>
                <div class="layui-input-inline">
                    <input name="address" id="address" placeholder="请输入"  value="" class="layui-input">
                </div>
            </div>
        </div>

        <div class="layui-form-item" >
            <div class="layui-inline">
                <label class="layui-form-label">email：</label>
                <div class="layui-input-inline">
                    <input name="email" id="email" placeholder="请输入"  value="" class="layui-input">
                </div>
            </div>

            <div class="layui-inline">
                <label class="layui-form-label">会员编码：</label>
                <div class="layui-input-inline">
                    <input name="memberCode" id="memberCode" placeholder="请输入"  value="" class="layui-input">
                </div>
            </div>
        </div>


        <div class="layui-form-item" >
            <div class="layui-inline">
                <label class="layui-form-label">介绍人：</label>
                <div class="layui-input-inline">
                    <input name="introducer" id="introducer" placeholder="请输入"  value="" class="layui-input">
                </div>
            </div>

            <div class="layui-inline">
                <label class="layui-form-label">负责美容师：</label>
                <div class="layui-input-inline">
                    <input name="primaryBeautician" id="primaryBeautician" placeholder="请输入"  value="" class="layui-input">
                </div>
            </div>
        </div>

        <div id="zyupload" class="zyupload"></div>

        <div class="layui-form-item" style="margin-left: 140px;">
            <!--<p id="btnGroup" class="pull-right">-->
                <button class="layui-btn save"  lay-submit="" lay-filter="*" >保存</button>
                <button class="layui-btn quxiao" >取消</button>
            <!--</p>-->
        </div>

        <input name="recordId"  class="recordId" type="hidden"  class="layui-input">


    </form>
  </div>
  </div>
  </body>
  </html>
<script type="text/javascript">



    //重新渲染表单

    function renderForm(){

        layui.use('form', function(){

            var form = layui.form;
            form.render();

        });

    }



    function child(data){
        var $ = layui.jquery;

        var recordId=data.recordId;
        $('#recordId').val(recordId);


        var memberName = data.memberName;
        $('#memberName').val(memberName);
        var tel = data.tel;
        $('#tel').val(tel);
        var gender = data.gender;
        $('#gender').val(gender);
        var weixin = data.weixin;
        $('#weixin').val(weixin);
        var birthday = data.birthday;
        $('#birthday').val(birthday);
        var zodiac = data.zodiac;
        $('#zodiac').val(zodiac);
        var memberGrade = data.memberGrade;
        $('#memberGrade').val(memberGrade);
        var bloodType = data.bloodType;
        $('#bloodType').val(bloodType);
        var height = data.height;
        $('#height').val(height);
        var weight = data.weight;
        $('#weight').val(weight);
        var lastDayOfMenses = data.lastDayOfMenses;
        $('#lastDayOfMenses').val(lastDayOfMenses);
        var cycleOfMenses = data.cycleOfMenses;
        $('#cycleOfMenses').val(cycleOfMenses);
        var periodOfMenses = data.periodOfMenses;
        $('#periodOfMenses').val(periodOfMenses);
        var remarkOfMenses = data.remarkOfMenses;
        $('#remarkOfMenses').val(remarkOfMenses);
        var profession = data.profession;
        $('#profession').val(profession);
        var address = data.address;
        $('#address').val(address);
        var email = data.email;
        $('#email').val(email);
        var memberCode = data.memberCode;
        $('#memberCode').val(memberCode);
        var introducer = data.introducer;
        $('#introducer').val(introducer);
        var primaryBeautician = data.primaryBeautician;
        $('#primaryBeautician').val(primaryBeautician);


        $.ajax({
            url:"/hy/basic/serviceSeries/queryServiceSeries",
            type:"get",
            data:{"SalonId":salonId},
            dataType:"json",
            success:function(dataJson){

                var selDom = $("#parentSeriesId");//根据id获取select的jquery对象



                $.each(dataJson.data, function (i, n) {
                    // $("#parentSeriesId").append("<option value='Value'>Text</option>");
                    selDom.append("<option value="+n.recordId+">"+n.seriesName+"</option>");//添加option
                    console.log(n.seriesName);
                });



                renderForm();

            },
            error:function(){
                alert("驳回异常")
            }
        });





        $("#zyupload").zyUpload({
            width            :   "650px",                 // 宽度
            height           :   "",                 // 宽度
            itemWidth        :   "140px",                 // 文件项的宽度
            itemHeight       :   "115px",                 // 文件项的高度
            url              :   "/hy/basic/pictures/fileUpload?record_type=2",              // 上传文件的路径
            fileType         :   ["jpg","png","txt","js","exe"],// 上传文件的类型
            fileSize         :   51200000,                // 上传文件的大小
            multiple         :   true,                    // 是否可以多个文件上传
            dragDrop         :   true,                    // 是否可以拖动上传文件
            tailor           :   true,                    // 是否可以裁剪图片
            del              :   true,                    // 是否可以删除文件
            finishDel        :   false,  				  // 是否在上传文件完成后删除预览
            /* 外部获得的回调接口 */
            onSelect: function(selectFiles, allFiles){    // 选择文件的回调方法  selectFile:当前选中的文件  allFiles:还没上传的全部文件
                console.info("当前选择了以下文件：");
                console.info(selectFiles);
            },
            onDelete: function(file, files){              // 删除一个文件的回调方法 file:当前删除的文件  files:删除之后的文件
                console.info("当前删除了此文件：");
                console.info(file.name);
            },
            onSuccess: function(file, response){          // 文件上传成功的回调方法
                console.info("此文件上传成功：");
                console.info(file.name);
                console.info("此文件上传到服务器地址：");
                console.info(response);
                response = JSON.parse(response);
                var list = response.data;
                var picList = $(".picList").val();
                var temp =[];
                if(picList!=""){
                    var tempList = JSON.parse(picList);
                    temp.push(tempList);
                }
                for(index in list){
                    console.log(list[index].recordId);
                    temp.push(list[index].recordId);
                }
                $(".picList").val(temp);
                console.info("picList============================================"+$(".picList").val());
                $("#uploadInf").append("<p>上传成功，文件地址是：" + response + "</p>");
            },
            onFailure: function(file, response){          // 文件上传失败的回调方法
                console.info("此文件上传失败：");
                console.info(file.name);
            },
            onComplete: function(response){           	  // 上传完成的回调方法
                console.info("文件上传完成");
                console.info(response);
            }
        });

    }





    layui.use(['element', 'layer', 'jquery','form','laydate','upload'], function () {
        var form = layui.form;
        var $ = layui.jquery;
        var laydate=layui.laydate;
        /* function quxiao(){
            alert(111);
        } */
        var $ = layui.jquery,
            upload = layui.upload;

        form.on('submit(*)', function(data){
            console.log(data.field);

            var dataList = data.field;
            var service = {};


            service.recordId = dataList.recordId;
            service.memberName = dataList.memberName;
            service.tel = dataList.tel;
            service.gender = dataList.gender;
            service.weixin = dataList.weixin;
            service.birthday = dataList.birthday;
            service.zodiac = dataList.zodiac;
            service.memberGrade = dataList.memberGrade;
            service.bloodType = dataList.bloodType;
            service.height = dataList.height;
            service.weight = dataList.weight;
            service.lastDayOfMenses = dataList.lastDayOfMenses;
            service.cycleOfMenses = dataList.cycleOfMenses;
            service.periodOfMenses = dataList.periodOfMenses;
            service.remarkOfMenses = dataList.remarkOfMenses;
            service.profession = dataList.profession;
            service.address = dataList.address;
            service.email = dataList.email;

            service.memberCode = dataList.memberCode;
            service.introducer = dataList.introducer;
            service.primaryBeautician = dataList.primaryBeautician;



            if(dataList.recordStatus=='on'){
                service.recordStatus = 1
            }else{
                service.recordStatus = 0;
            }

            var url = '/hy/basic/member/addMember';
            var picList= $(".picList").val();
            $.ajax({
                type:'POST',
                url:url,
                data:{
                    condition:JSON.stringify(service),
                    picIdList:picList,
                    comeFrom:"PC"
                } ,
                contentType: "application/x-www-form-urlencoded",
                success: function(data){
                    alert("操作成功！");
                    window.parent.location.reload(); //刷新父页面
                    var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
                    parent.layer.close(index);  // 关闭layer
                    /* alert("操作成功");
                    if(type=="update"){
                        window.parent.location.reload(); //刷新父页面
                        var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
                        parent.layer.close(index);  // 关闭layer
                    }else{
                        window.location.reload();
                        //window.location.href="${basePath}ryOrderConfig/queryList";
                    } */

                    //window.location.href="${basePath}ryOrderConfig/queryList";
                },
                error:function(data){
                    alert("操作失败");
                    console.log(data);
                }
            })
            return false;
        });

    })


    layui.use('laydate', function() {
        var laydate = layui.laydate;
        //常规用法
        laydate.render({
            elem: '#lastDayOfMenses'
        });
        laydate.render({
            elem: '#birthday'
        });
    });





</script>  